package logic

import (
	"context"
	"gitee.com/jmdvirus/jkgo/jk/jklog"

	"feitianstudyservice/internal/svc"
	"feitianstudyservice/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type FeiTianStudyServiceAddLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewFeiTianStudyServiceAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FeiTianStudyServiceAddLogic {
	return &FeiTianStudyServiceAddLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *FeiTianStudyServiceAddLogic) FeiTianStudyServiceAdd(req *types.EventRequest) (resp *types.GenResponse, err error) {
	jklog.L().Infoln("add title ", req.Title)
	data := map[string]interface{}{
		"title": req.Title,
		"class": req.Class,
		"state": req.State,
		"time":  req.Time,
	}
	err = AddWordRecord(data)
	if err != nil {
		jklog.L().Errorln("add error ", err)
	}
	return EventAdd(*req), nil
}
